//
//  DicRequest.m
//  MBObjectServer
//
//  Created by Juvid on 14-3-5.
//  Copyright (c) 2014年 MBpayer. All rights reserved.
//

#import "DicRequest.h"
//#import "definehead.h"
@implementation DicRequest
+(MBBaseServer *)SearchSaleProducts:(NSString *)prodName
                                    ProdID:(NSString *)prodID
                                  StartNum:(int)startNum
                                    EndNum:(int)endNum{
  MBBaseServer  *baseserver = [[MBBaseServer alloc]init];
    NSMutableDictionary* postDic=[[NSMutableDictionary alloc]init];
    [postDic setObject:prodName forKey:@"ProdName"];
     [postDic setObject:prodID forKey:@"ProdID"];
     [postDic setValue:[NSString stringWithFormat:@"%d",startNum] forKey:@"StartNum"];
     [postDic setObject:[NSString stringWithFormat:@"%d",endNum] forKey:@"EndNum"];
     [baseserver setRequestStyle:nil andSetPathString:@"billsale_handler.ashx" andSetHeadString:nil andActionName:@"SearchSaleProducts" andSetMainDictionary:postDic];
    return baseserver;
}
+(MBBaseServer *)ScanBarCodeIntoBillEntity:(NSString *)BarCode
                                       Qty:(NSString *)Qty
                               ContainerID:(NSString *)ContainerID
                                     IsJudgePrice:(NSString *)IsJudgePrice
                                  StartNum:(int)startNum
                                    EndNum:(int)endNum{
     MBBaseServer  *baseserver = [[MBBaseServer alloc]init];
    baseserver.isStartLoad=YES;
    NSMutableDictionary* postDic=[[NSMutableDictionary alloc]init];
    [postDic setObject:[self GetOrgCode] forKey:@"OrgCode"];
    
    
    [postDic setObject:BarCode forKey:@"BarCode"];
    [postDic setValue:Qty forKey:@"Qty"];
    [postDic setObject:[DicRequest GetUserID] forKey:@"SellerUserID"];
    [postDic setObject:ContainerID forKey:@"ContainerID"];
    [postDic setObject:IsJudgePrice forKey:@"IsJudgePrice"];
    [postDic setValue:[NSNumber numberWithInt:startNum] forKey:@"StartNum"];
    [postDic setObject:[NSNumber numberWithInt:endNum] forKey:@"EndNum"];
    [baseserver setRequestStyle:nil andSetPathString:@"billsale_handler.ashx" andSetHeadString:nil andActionName:@"ScanBarCodeIntoBillEntity" andSetMainDictionary:postDic];
    return baseserver;
}
//库存查询
+(MBBaseServer *)GetStockJson:(NSString *)OrgCode
                       ProdID:(NSString *)ProdID
                      {
    MBBaseServer  *baseserver = [[MBBaseServer alloc]init];
    baseserver.isStartLoad=YES;
    NSMutableDictionary* postDic=[[NSMutableDictionary alloc]init];
    [postDic setObject:OrgCode forKey:@"OrgCode"];
    [postDic setObject:ProdID forKey:@"ProdID"];
    [baseserver setRequestStyle:nil andSetPathString:@"stock_handler.ashx" andSetHeadString:nil andActionName:@"GetStockJson" andSetMainDictionary:postDic];
    return baseserver;
}
//获取小票详情
+(MBBaseServer *)RetrieveBillSale:(NSString *)saleID{
    MBBaseServer  *baseserver = [[MBBaseServer alloc]init];
    NSMutableDictionary* postDic=[[NSMutableDictionary alloc]init];
    [postDic setObject:saleID forKey:@"SaleID"];
    NSMutableArray * enumArray = [[NSMutableArray alloc]init] ;
    for (int i = 0 ; i < 4 ; i++) {
        NSNumber * enums = [NSNumber numberWithInt:i];
        [enumArray addObject:enums] ;
    }
    [postDic setObject:enumArray forKey:@"BillSaleWrapEnums"];
    [baseserver setRequestStyle:nil andSetPathString:@"billsale_handler.ashx" andSetHeadString:nil andActionName:@"RetrieveBillSale" andSetMainDictionary:postDic];
    return baseserver;
}

//交易查询
+(MBBaseServer *)RetrieveBillSaleHeads:(NSString *)saleNo
                              StartNum:(int)startNum
                                EndNum:(int)endNum{
    MBBaseServer  *baseserver = [[MBBaseServer alloc]init];
    NSMutableDictionary* postDic=[[NSMutableDictionary alloc]init];
//    [postDic setObject:[self GetOrgCode] forKey:@"OrgCode"];
    [postDic setObject:@"A01339S011" forKey:@"OrgCode"];
    if (![saleNo isEqual:@""]) {
        [postDic setObject:saleNo forKey:@"SaleNo"];
    }
    [postDic setValue:[NSNumber numberWithInt:startNum] forKey:@"StartNum"];
    [postDic setObject:[NSNumber numberWithInt:endNum] forKey:@"EndNum"];
    [baseserver setRequestStyle:nil andSetPathString:@"billsale_handler.ashx" andSetHeadString:nil andActionName:@"RetrieveBillSaleHeads" andSetMainDictionary:postDic];
    return baseserver;
}




+(void)ShowAlert:(NSString *)title Message:(NSString *)message{
    UIAlertView * alertview = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alertview show];
}
//
+(NSString *)GetUserID{
//     NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
//    [userDefaults objectForKey:@"UserID"];
    return [[NSUserDefaults standardUserDefaults] objectForKey:kUserID];
}
+(NSString *)GetOrgCode
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kOrgCode];
    
}
+(NSString *)GetShopName
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kShopName];

}

+(NSString *)GetUserName{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kUserName];
    
}
+(NSString *)GetShopID{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kShopID];
}
+(NSString *)GetVIPCode{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kVIPCode];
}
@end
